name: pre-commit run_id: commands[0] env HOME: /home/jenkins env LANG: C.UTF-8 env PATH: /w/workspace/integration-test-tox-verify-master/.tox/pre-commit/bin:/opt/pyenv/bin:/tmp/venv-nZsr/bin:/opt/pyenv/shims:/home/jenkins/.local/bin:/opt/sdkman/candidates/mvnd/current/bin:/opt/sdkman/candidates/maven/current/bin:/opt/sdkman/candidates/java/current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/opt/puppetlabs/bin env PIP_DISABLE_PIP_VERSION_CHECK: 1 env PIP_USER: 0 env PYTHONHASHSEED: 1203447505 env PYTHONIOENCODING: utf-8 env SSH_AUTH_SOCK: ******************************** env TOX_ENV_DIR: /w/workspace/integration-test-tox-verify-master/.tox/pre-commit env TOX_ENV_NAME: pre-commit env TOX_WORK_DIR: /w/workspace/integration-test-tox-verify-master/.tox env VIRTUAL_ENV: /w/workspace/integration-test-tox-verify-master/.tox/pre-commit env __TOX_ENVIRONMENT_VARIABLE_ORIGINAL_CI: true metadata pid: 2586 cwd: /w/workspace/integration-test-tox-verify-master allow: /w/workspace/integration-test-tox-verify-master/.tox/pre-commit/bin/* cmd: pre-commit run --all-files --show-diff-on-failure exit_code: 1 [INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks. [WARNING] repo `https://github.com/pre-commit/pre-commit-hooks` uses deprecated stage names (commit, push) which will be removed in a future version. Hint: often `pre-commit autoupdate --repo https://github.com/pre-commit/pre-commit-hooks` will fix this. if it does not -- consider reporting an issue to that repo. [INFO] Initializing environment for https://github.com/PyCQA/flake8. [INFO] Initializing environment for https://github.com/psf/black. [INFO] Initializing environment for https://github.com/MarketSquare/robotframework-tidy. [INFO] Initializing environment for https://github.com/MarketSquare/robotframework-tidy:robotframework==6.1.1. [INFO] Initializing environment for https://github.com/jorisroovers/gitlint. [INFO] Initializing environment for https://github.com/jorisroovers/gitlint:./gitlint-core[trusted-deps]. [INFO] Initializing environment for local:rstcheck,sphinx. [INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... [INFO] Installing environment for https://github.com/PyCQA/flake8. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... [INFO] Installing environment for https://github.com/psf/black. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... [INFO] Installing environment for https://github.com/MarketSquare/robotframework-tidy. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... [INFO] Installing environment for local. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... trim trailing whitespace.................................................Passed flake8...................................................................Failed - hook id: flake8 - exit code: 1 tools/fastbgp/play2.py:2747:28: W292 no newline at end of file threaded_job(arguments) ^ tools/fastbgp/play3.py:2680:28: W292 no newline at end of file threaded_job(arguments) ^ black....................................................................Failed - hook id: black - files were modified by this hook reformatted tools/fastbgp/play2.py reformatted tools/fastbgp/play3.py All done! ✨ 🍰 ✨ 2 files reformatted, 105 files left unchanged. robotidy.................................................................Passed rstcheck.................................................................Passed pre-commit hook(s) made changes. If you are seeing this message in CI, reproduce locally with: `pre-commit run --all-files`. To run `pre-commit` as part of git workflow, use `pre-commit install`. All changes made by hooks: diff --git a/tools/fastbgp/play2.py b/tools/fastbgp/play2.py index ca7dfd28..60a23a67 100755 --- a/tools/fastbgp/play2.py +++ b/tools/fastbgp/play2.py @@ -179,7 +179,9 @@ def parse_arguments(): str_help = "Link-State NLRI supported" parser.add_argument("--bgpls", default=False, type=bool, help=str_help) str_help = "Link-State NLRI: Identifier" - parser.add_argument("-lsid", "--lsid", dest="lsid", default=1, type=int, help=str_help) + parser.add_argument( + "-lsid", "--lsid", dest="lsid", default=1, type=int, help=str_help + ) str_help = "Link-State NLRI: Policy Color" parser.add_argument( "--color", "-lstid", dest="color", default=100, type=int, help=str_help @@ -835,12 +837,8 @@ class MessageGenerator(object): Returns: :return: dictionary of LS NLRI parameters and values """ - identifier = self.ls_nlri_default["Identifier"] + int( - index / self.lsid_step - ) - color = self.ls_nlri_default["Color"] + int( - index / self.color_step - ) + identifier = self.ls_nlri_default["Identifier"] + int(index / self.lsid_step) + color = self.ls_nlri_default["Color"] + int(index / self.color_step) discriminator = self.ls_nlri_default["Discriminator"] + int( index / self.discriminator_step ) @@ -1492,14 +1490,22 @@ class MessageGenerator(object): # SR Policy Candidate Path Descriptor TLV (TLV 554) - RFC 9857 Section 4 tlv_554_val = ( - struct.pack("B", int(ls_nlri["ProtocolOrigin"])) # 1 octet: Protocol-Origin + struct.pack( + "B", int(ls_nlri["ProtocolOrigin"]) + ) # 1 octet: Protocol-Origin + b"\x00" # 1 octet: Flags (E=0, O=0 for IPv4) + b"\x00\x00" # 2 octets: Reserved + struct.pack(">I", int(ls_nlri["Endpoint"])) # 4 octets: Endpoint + struct.pack(">I", int(ls_nlri["Color"])) # 4 octets: Policy Color - + struct.pack(">I", int(ls_nlri["OriginatorASN"])) # 4 octets: Originator ASN - + struct.pack(">I", int(ls_nlri["OriginatorAddress"])) # 4 octets: Originator Address - + struct.pack(">I", int(ls_nlri["Discriminator"])) # 4 octets: Discriminator + + struct.pack( + ">I", int(ls_nlri["OriginatorASN"]) + ) # 4 octets: Originator ASN + + struct.pack( + ">I", int(ls_nlri["OriginatorAddress"]) + ) # 4 octets: Originator Address + + struct.pack( + ">I", int(ls_nlri["Discriminator"]) + ) # 4 octets: Discriminator ) tlv_554 = struct.pack(">HH", 554, len(tlv_554_val)) + tlv_554_val @@ -2744,4 +2750,4 @@ def threaded_job(arguments): if __name__ == "__main__": arguments = parse_arguments() logger = create_logger(arguments.loglevel, arguments.logfile) - threaded_job(arguments) \ No newline at end of file + threaded_job(arguments) diff --git a/tools/fastbgp/play3.py b/tools/fastbgp/play3.py index 234e62a5..8a9edcad 100755 --- a/tools/fastbgp/play3.py +++ b/tools/fastbgp/play3.py @@ -179,7 +179,9 @@ def parse_arguments(): str_help = "Link-State NLRI supported" parser.add_argument("--bgpls", default=False, type=bool, help=str_help) str_help = "Link-State NLRI: Identifier" - parser.add_argument("-lsid", "--lsid", dest="lsid", default=1, type=int, help=str_help) + parser.add_argument( + "-lsid", "--lsid", dest="lsid", default=1, type=int, help=str_help + ) str_help = "Link-State NLRI: Policy Color" parser.add_argument( "--color", "-lstid", dest="color", default=100, type=int, help=str_help @@ -920,18 +922,16 @@ class MessageGenerator(object): """ if self.nlri_type == 6: identifier = self.base_identifier + int(index / self.lsid_step) - sid = ipaddr.IPv6Address(int(self.base_sid) + int(index / self.srv6_sid_step)) + sid = ipaddr.IPv6Address( + int(self.base_sid) + int(index / self.srv6_sid_step) + ) srv6_nlri_values = self.srv6_nlri_default.copy() srv6_nlri_values["Identifier"] = identifier srv6_nlri_values["SID"] = sid return srv6_nlri_values - identifier = self.ls_nlri_default["Identifier"] + int( - index / self.lsid_step - ) - color = self.ls_nlri_default["Color"] + int( - index / self.color_step - ) + identifier = self.ls_nlri_default["Identifier"] + int(index / self.lsid_step) + color = self.ls_nlri_default["Color"] + int(index / self.color_step) discriminator = self.ls_nlri_default["Discriminator"] + int( index / self.discriminator_step ) @@ -1139,151 +1139,72 @@ class MessageGenerator(object): optional_parameters_hex = b"" if self.rfc4760 or self.allf: optional_parameter_hex = ( - b"\x02" - b"\x06" - b"\x01" - b"\x04" - b"\x00\x01" - b"\x00" - b"\x01" + b"\x02" b"\x06" b"\x01" b"\x04" b"\x00\x01" b"\x00" b"\x01" ) optional_parameters_hex += optional_parameter_hex if self.ipv6 or self.allf: optional_parameter_hex = ( - b"\x02" - b"\x06" - b"\x01" - b"\x04" - b"\x00\x02" - b"\x00" - b"\x01" + b"\x02" b"\x06" b"\x01" b"\x04" b"\x00\x02" b"\x00" b"\x01" ) optional_parameters_hex += optional_parameter_hex if self.bgpls or self.allf: optional_parameter_hex = ( - b"\x02" - b"\x06" - b"\x01" - b"\x04" - b"\x40\x04" - b"\x00" - b"\x47" + b"\x02" b"\x06" b"\x01" b"\x04" b"\x40\x04" b"\x00" b"\x47" ) optional_parameters_hex += optional_parameter_hex if self.evpn or self.allf: optional_parameter_hex = ( - b"\x02" - b"\x06" - b"\x01" - b"\x04" - b"\x00\x19" - b"\x00" - b"\x46" + b"\x02" b"\x06" b"\x01" b"\x04" b"\x00\x19" b"\x00" b"\x46" ) optional_parameters_hex += optional_parameter_hex if self.mvpn or self.allf: optional_parameter_hex = ( - b"\x02" - b"\x06" - b"\x01" - b"\x04" - b"\x00\x01" - b"\x00" - b"\x05" + b"\x02" b"\x06" b"\x01" b"\x04" b"\x00\x01" b"\x00" b"\x05" ) optional_parameters_hex += optional_parameter_hex optional_parameter_hex = ( - b"\x02" - b"\x06" - b"\x01" - b"\x04" - b"\x00\x02" - b"\x00" - b"\x05" + b"\x02" b"\x06" b"\x01" b"\x04" b"\x00\x02" b"\x00" b"\x05" ) optional_parameters_hex += optional_parameter_hex if self.l3vpn_mcast or self.allf: optional_parameter_hex = ( - b"\x02" - b"\x06" - b"\x01" - b"\x04" - b"\x00\x01" - b"\x00" - b"\x81" + b"\x02" b"\x06" b"\x01" b"\x04" b"\x00\x01" b"\x00" b"\x81" ) optional_parameters_hex += optional_parameter_hex optional_parameter_hex = ( - b"\x02" - b"\x06" - b"\x01" - b"\x04" - b"\x00\x02" - b"\x00" - b"\x81" + b"\x02" b"\x06" b"\x01" b"\x04" b"\x00\x02" b"\x00" b"\x81" ) optional_parameters_hex += optional_parameter_hex if self.l3vpn or self.allf: optional_parameter_hex = ( - b"\x02" - b"\x06" - b"\x01" - b"\x04" - b"\x00\x01" - b"\x00" - b"\x80" + b"\x02" b"\x06" b"\x01" b"\x04" b"\x00\x01" b"\x00" b"\x80" ) optional_parameters_hex += optional_parameter_hex optional_parameter_hex = ( - b"\x02" - b"\x06" - b"\x01" - b"\x04" - b"\x00\x02" - b"\x00" - b"\x80" + b"\x02" b"\x06" b"\x01" b"\x04" b"\x00\x02" b"\x00" b"\x80" ) optional_parameters_hex += optional_parameter_hex if self.rt_constrain or self.allf: optional_parameter_hex = ( - b"\x02" - b"\x06" - b"\x01" - b"\x04" - b"\x00\x01" - b"\x00" - b"\x84" + b"\x02" b"\x06" b"\x01" b"\x04" b"\x00\x01" b"\x00" b"\x84" ) optional_parameters_hex += optional_parameter_hex if self.bgplu or self.allf: optional_parameter_hex = ( - b"\x02" - b"\x06" - b"\x01" - b"\x04" - b"\x00\x01" - b"\x00" - b"\x04" + b"\x02" b"\x06" b"\x01" b"\x04" b"\x00\x01" b"\x00" b"\x04" ) optional_parameters_hex += optional_parameter_hex - optional_parameter_hex = ( - b"\x02" - b"\x06" - b"\x41" - b"\x04" - ) - optional_parameter_hex += struct.pack( - ">I", my_autonomous_system - ) + optional_parameter_hex = b"\x02" b"\x06" b"\x41" b"\x04" + optional_parameter_hex += struct.pack(">I", my_autonomous_system) optional_parameters_hex += optional_parameter_hex if self.grace != 8: @@ -1466,48 +1387,20 @@ class MessageGenerator(object): path_attributes_hex = b"" if not self.skipattr: - path_attributes_hex += ( - b"\x40" - b"\x01" - b"\x01" - b"\x00" - ) - path_attributes_hex += ( - b"\x40" - b"\x02" - b"\x06" - b"\x02" - b"\x01" - ) + path_attributes_hex += b"\x40" b"\x01" b"\x01" b"\x00" + path_attributes_hex += b"\x40" b"\x02" b"\x06" b"\x02" b"\x01" my_as_hex = struct.pack(">I", my_autonomous_system) path_attributes_hex += my_as_hex - path_attributes_hex += ( - b"\x40" - b"\x05" - b"\x04" - b"\x00\x00\x00\x64" - ) + path_attributes_hex += b"\x40" b"\x05" b"\x04" b"\x00\x00\x00\x64" if nlri_prefixes != []: - path_attributes_hex += ( - b"\x40" - b"\x03" - b"\x04" - ) + path_attributes_hex += b"\x40" b"\x03" b"\x04" next_hop_hex = struct.pack(">I", int(next_hop)) path_attributes_hex += next_hop_hex if originator_id is not None: - path_attributes_hex += ( - b"\x80" - b"\x09" - b"\x04" - ) + path_attributes_hex += b"\x80" b"\x09" b"\x04" path_attributes_hex += struct.pack(">I", int(originator_id)) if cluster_list_item is not None: - path_attributes_hex += ( - b"\x80" - b"\x0a" - b"\x04" - ) + path_attributes_hex += b"\x80" b"\x0a" b"\x04" path_attributes_hex += struct.pack(">I", int(cluster_list_item)) if self.bgpls and not end_of_rib: @@ -1552,17 +1445,12 @@ class MessageGenerator(object): mp_reach_content = ( b"\x40\x04" b"\x47" - b"\x04" - + struct.pack(">I", int(next_hop)) - + b"\x00" - + nlri + b"\x04" + struct.pack(">I", int(next_hop)) + b"\x00" + nlri ) path_attributes_hex += ( b"\x80" - b"\x0e" - + struct.pack("B", len(mp_reach_content)) - + mp_reach_content + b"\x0e" + struct.pack("B", len(mp_reach_content)) + mp_reach_content ) elif self.nlri_type == 6: @@ -1602,9 +1490,7 @@ class MessageGenerator(object): path_attributes_hex += ( b"\x80" - b"\x0e" - + struct.pack("B", len(mp_reach_content)) - + mp_reach_content + b"\x0e" + struct.pack("B", len(mp_reach_content)) + mp_reach_content ) # 5. BGP-LS Attribute (Attribute 29) @@ -1630,9 +1516,7 @@ class MessageGenerator(object): attr_29_content = tlv_1250 + tlv_1252 path_attributes_hex += ( b"\x80" - b"\x1d" - + struct.pack("B", len(attr_29_content)) - + attr_29_content + b"\x1d" + struct.pack("B", len(attr_29_content)) + attr_29_content ) total_path_attributes_length = len(path_attributes_hex) @@ -2677,4 +2561,4 @@ def threaded_job(arguments): if __name__ == "__main__": arguments = parse_arguments() logger = create_logger(arguments.loglevel, arguments.logfile) - threaded_job(arguments) \ No newline at end of file + threaded_job(arguments)